const userModel = require('../lib/mysql.js')
const moment = require('moment')
const checkLogin = require('../middlewares/check.js').checkLogin;

/**
 * 首页
 */
exports.getHome = async ctx => {
    ctx.render('home')
}

/**
 * test頁面
 */
exports.getContent = async ctx => {
    ctx.render('index', { title:'LYB' })
}

/**
 * 接口
 */
exports.test = async ctx => {
    const data = {
        name: ctx.request.body.name,
        age: ctx.request.body.age,
        createdAt: Date.now()
    };
    if( data.name && data.age ) {
        ctx.body = { err: 0, msg: '登記成功！', data: data }
    }else {
        ctx.body = { err: 1, msg: 'invalid request' }
    }
}